package com.hnue.k60b.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hnue.k60b.newapplication.R;
import com.hnue.k60b.utils.Variables;

public class CatagoryAdapter extends ArrayAdapter<String> {

	// moi hang sẽ có 2 cột, icon và tên báo
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// khi tao ra view mới, cho phép add thêm 1 hàng mới
		// systemservice sẽ trả về 1 object
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(context.LAYOUT_INFLATER_SERVICE);
		// khởi tạo 1 dòng
		View rowview = inflater.inflate(R.layout.catagory, parent, false);
		int b = Color.rgb(135, 206, 235);
		rowview.setBackgroundColor(b);
		// Color color = new Color();
		// add icon và textview
		ImageView iv = (ImageView) rowview.findViewById(R.id.ivIcon);
		TextView tv = (TextView) rowview.findViewById(R.id.tvCatagory);
		iv.setImageResource(ivIcon);
		tv.setText(catagories[position]);
		return rowview;
	}

	private Context context;
	private String[] catagories;
	private int ivIcon;

	public CatagoryAdapter(Context context, int ivIcon, String[] catagories) {
		super(context, ivIcon, catagories);
		this.context = context;
		this.ivIcon = ivIcon;
		this.catagories = catagories;
	}

}
